include("shared.lua")

language.Add("ori_beam_cannon", "Ori Beam")

ENT.cycleInterval = 0.1

local glowMaterial = Material("sprites/portalglow")
local glowSize = 0

function ENT:Think()
   if(self:IsCharging()) then
      glowSize = glowSize + 5
   elseif(self:IsFiring() && glowSize > 0) then
      glowSize = math.max(glowSize - 10, 0)
   else
      glowSize = 0
   end

   self:NextThink(CurTime() + self.cycleInterval)
   return true
end

function ENT:Draw()
   self.BaseClass.Draw(self, false)
   
   if(glowSize < 1) then
      return
   end
      
   render.SetMaterial(glowMaterial)
   render.DrawSprite(self:GetEmitterPos(), 
                     glowSize, glowSize, 
                     self:GetBeamColour())
end
